import { InjectionToken } from "tsyringe";
import { IListener } from "../../core/listener";
import { ISender } from "../../core/sender";
import { CLOUD_CODE, ICloudCode } from "../../tokens/const";
import * as utils from '../../utils'
import { ScriptManager } from "../scriptManager";

export class CloudCodeListener implements IListener<ICloudCode> {
    type: InjectionToken<ICloudCode> = CLOUD_CODE;
    on = (payload: ICloudCode, manager: ISender) => {
        const scriptmanager = utils.tryGet(ScriptManager)
        scriptmanager.start(payload.id, payload.code);
    }
}